FROM python:3.10.13-slim

LABEL Description="sceript-python-slim-image" Author="xmz" Version="1.0"

# 设置无交互模式，防止安装时出现交互提示
ENV DEBIAN_FRONTEND=noninteractive
# 设置系统编码为 UTF-8
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
# 设置环境
ENV env='prd'

WORKDIR /opt/

COPY debian.sources /etc/apt/sources.list.d/
COPY requirements.txt /tmp/


# 更新系统并安装必要工具
RUN apt-get update && apt-get install -y --no-install-recommends \
    wget \
    gnupg \
    ca-certificates \
    fonts-liberation \
    libappindicator3-1 \
    libasound2 \
    libatk-bridge2.0-0 \
    libcups2 \
    libdbus-1-3 \
    libnspr4 \
    libnss3 \
    libx11-xcb1 \
    libxcomposite1 \
    libxcursor1 \
    libxdamage1 \
    libxrandr2 \
    libgbm1 \
    libgtk-3-0 \
    libxshmfence1 \
    xdg-utils && \
    rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y --no-install-recommends \
    wget \
    ca-certificates && \
    wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
    apt-get install -y ./google-chrome-stable_current_amd64.deb && \
    rm -rf google-chrome-stable_current_amd64.deb && \
    rm -rf /var/lib/apt/lists/*


# 验证 Chrome 安装
RUN google-chrome --version


RUN apt-get update \
    && apt-get upgrade -y \
    && apt-get install -y --no-install-recommends locales procps gcc default-libmysqlclient-dev supervisor git\
	&& pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple \
	&& pip install --upgrade wheel -i https://mirrors.aliyun.com/pypi/simple \
	&& pip install -r /tmp/requirements.txt -i https://mirrors.aliyun.com/pypi/simple \
	&& rm -rf /tmp/* /usr/include/* /var/log/* /var/lib/apt/* /var/cache/*  /var/lib/apt/lists/*  /usr/local/include/python3.10m/* \
	&& apt-get autoclean clean

# 设置时区
ENV TZ='Asia/Shanghai'
ENV ENV=prd

CMD ["python"]